home *** CD-ROM | disk | FTP | other *** search
- #ifndef lint
- char yysccsid[] = "@(#)yaccpar 1.4 (Berkeley) 02/25/90";
- #endif
- #line 30 "flxparse.y"
-
- #include "flexdef.h"
-
- #ifndef lint
-
- static char copyright[] =
- "@(#) Copyright (c) 1989 The Regents of the University of California.\n";
- static char CR_continuation[] = "@(#) All rights reserved.\n";
-
- static char rcsid[] =
- "@(#) $Header: /tan/u1/ice/pisces/flex/RCS/flxparse.y,v 1.1 91/02/06 15:58:44 fontana Exp $ (LBL)";
-
- #endif
-
- int pat, scnum, eps, headcnt, trailcnt, anyccl, lastchar, i, actvp, rulelen;
- int trlcontxt, xcluflg, cclsorted, varlength, variable_trail_rule;
- char clower();
-
- static int madeany = false; /* whether we've made the '.' character class */
- int previous_continued_action; /* whether the previous rule's action was '|' */
-
- #line 27 "y_tab.c"
- #define CHAR 257
- #define NUMBER 258
- #define SECTEND 259
- #define SCDECL 260
- #define XSCDECL 261
- #define WHITESPACE 262
- #define NAME 263
- #define PREVCCL 264
- #define EOF_OP 265
- #define YYERRCODE 256
- short yylhs[] = { -1,
- 0, 1, 2, 2, 2, 3, 6, 6, 7, 7,
- 7, 4, 4, 5, 8, 8, 8, 8, 8, 8,
- 8, 9, 12, 12, 12, 11, 11, 10, 10, 10,
- 14, 13, 13, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 16, 16, 18, 18, 18,
- 17, 17,
- };
- short yylen[] = { 2,
- 5, 0, 5, 0, 2, 1, 1, 1, 3, 1,
- 1, 4, 0, 0, 4, 3, 3, 2, 2, 1,
- 1, 3, 3, 1, 1, 1, 0, 3, 2, 1,
- 2, 2, 1, 2, 2, 2, 6, 5, 4, 1,
- 1, 1, 3, 3, 1, 3, 4, 4, 2, 0,
- 2, 0,
- };
- short yydefred[] = { 2,
- 0, 0, 0, 0, 5, 6, 7, 8, 13, 0,
- 14, 0, 0, 11, 10, 0, 21, 45, 42, 20,
- 0, 0, 40, 52, 0, 0, 0, 0, 0, 0,
- 0, 0, 41, 0, 3, 0, 25, 24, 0, 0,
- 0, 50, 0, 12, 19, 0, 0, 26, 0, 31,
- 18, 0, 0, 34, 35, 36, 0, 9, 17, 22,
- 0, 51, 43, 44, 0, 0, 46, 0, 16, 0,
- 0, 23, 47, 0, 15, 0, 39, 48, 0, 38,
- 37,
- };
- short yydgoto[] = { 1,
- 2, 4, 9, 11, 13, 10, 16, 27, 28, 29,
- 51, 39, 30, 31, 32, 33, 40, 43,
- };
- short yysindex[] = { 0,
- 0, -233, 15, -171, 0, 0, 0, 0, 0, -224,
- 0, -187, -32, 0, 0, -9, 0, 0, 0, 0,
- -28, -185, 0, 0, -28, -50, 42, -30, -15, -28,
- -28, 23, 0, -205, 0, -15, 0, 0, 5, -29,
- -6, 0, -86, 0, 0, -28, -15, 0, -28, 0,
- 0, 23, -28, 0, 0, 0, -198, 0, 0, 0,
- -186, 0, 0, 0, -84, 34, 0, -15, 0, -28,
- -22, 0, 0, -177, 0, -110, 0, 0, -43, 0,
- 0,
- };
- short yyrindex[] = { 0,
- 0, -165, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 83, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, -82, 0, 0, 75, 7,
- 0, -10, 0, 0, 0, 75, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 75, 0, 0, 0,
- 0, -7, 9, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, -80, 0, 75, 0, 10,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0,
- };
- short yygindex[] = { 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 47,
- 6, 0, 24, 0, 17, 0, 0, 49,
- };
- #define YYTABLESIZE 257
- short yytable[] = { 33,
- 35, 24, 32, 24, 63, 24, 67, 25, 73, 25,
- 50, 25, 49, 23, 80, 23, 30, 23, 29, 28,
- 48, 76, 3, 33, 5, 33, 32, 22, 32, 33,
- 33, 50, 32, 32, 64, 33, 33, 12, 32, 32,
- 50, 59, 30, 42, 29, 28, 52, 30, 61, 29,
- 28, 44, 69, 30, 53, 29, 28, 58, 26, 71,
- 26, 21, 26, 46, 54, 55, 60, 36, 14, 52,
- 37, 41, 70, 75, 47, 15, 72, 38, 74, 78,
- 33, 81, 1, 32, 27, 56, 52, 6, 7, 8,
- 65, 0, 68, 4, 4, 4, 0, 0, 0, 0,
- 0, 0, 77, 0, 0, 0, 0, 0, 49, 0,
- 0, 0, 0, 33, 0, 0, 32, 49, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 30, 0, 29, 28, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 57, 0, 79, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 66, 0, 66, 0, 50, 0, 49, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 17, 18, 0, 18, 62, 18, 0,
- 0, 19, 20, 19, 45, 19, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 33, 0, 0, 32,
- 0, 0, 34, 33, 0, 0, 32,
- };
- short yycheck[] = { 10,
- 10, 34, 10, 34, 34, 34, 93, 40, 93, 40,
- 93, 40, 93, 46, 125, 46, 10, 46, 10, 10,
- 36, 44, 256, 34, 10, 36, 34, 60, 36, 40,
- 41, 47, 40, 41, 41, 46, 47, 262, 46, 47,
- 47, 36, 36, 94, 36, 36, 30, 41, 44, 41,
- 41, 10, 47, 47, 31, 47, 47, 263, 91, 258,
- 91, 94, 91, 94, 42, 43, 62, 21, 256, 53,
- 256, 25, 49, 68, 28, 263, 263, 263, 45, 257,
- 91, 125, 0, 91, 10, 63, 70, 259, 260, 261,
- 42, -1, 46, 259, 260, 261, -1, -1, -1, -1,
- -1, -1, 125, -1, -1, -1, -1, -1, 124, -1,
- -1, -1, -1, 124, -1, -1, 124, 124, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 124, -1, 124, 124, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 123, -1, 258, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 257, -1, 257, -1, 257, -1, 257, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 256, 257, -1, 257, 257, 257, -1,
- -1, 264, 265, 264, 265, 264, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 257, -1, -1, 257,
- -1, -1, 262, 264, -1, -1, 264,
- };
- #define YYFINAL 1
- #ifndef YYDEBUG
- #define YYDEBUG 0
- #endif
- #define YYMAXTOKEN 265
- #if YYDEBUG
- char *yyname[] = {
- "end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,"'\"'",0,"'$'",0,0,0,"'('","')'","'*'","'+'","','","'-'",
- "'.'","'/'",0,0,0,0,0,0,0,0,0,0,0,0,"'<'",0,"'>'","'?'",0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,"']'","'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'","'|'","'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"CHAR",
- "NUMBER","SECTEND","SCDECL","XSCDECL","WHITESPACE","NAME","PREVCCL","EOF_OP",
- };
- char *yyrule[] = {
- "$accept : goal",
- "goal : initlex sect1 sect1end sect2 initforrule",
- "initlex :",
- "sect1 : sect1 startconddecl WHITESPACE namelist1 '\\n'",
- "sect1 :",
- "sect1 : error '\\n'",
- "sect1end : SECTEND",
- "startconddecl : SCDECL",
- "startconddecl : XSCDECL",
- "namelist1 : namelist1 WHITESPACE NAME",
- "namelist1 : NAME",
- "namelist1 : error",
- "sect2 : sect2 initforrule flexrule '\\n'",
- "sect2 :",
- "initforrule :",
- "flexrule : scon '^' re eol",
- "flexrule : scon re eol",
- "flexrule : '^' re eol",
- "flexrule : re eol",
- "flexrule : scon EOF_OP",
- "flexrule : EOF_OP",
- "flexrule : error",
- "scon : '<' namelist2 '>'",
- "namelist2 : namelist2 ',' NAME",
- "namelist2 : NAME",
- "namelist2 : error",
- "eol : '$'",
- "eol :",
- "re : re '|' series",
- "re : re2 series",
- "re : series",
- "re2 : re '/'",
- "series : series singleton",
- "series : singleton",
- "singleton : singleton '*'",
- "singleton : singleton '+'",
- "singleton : singleton '?'",
- "singleton : singleton '{' NUMBER ',' NUMBER '}'",
- "singleton : singleton '{' NUMBER ',' '}'",
- "singleton : singleton '{' NUMBER '}'",
- "singleton : '.'",
- "singleton : fullccl",
- "singleton : PREVCCL",
- "singleton : '\"' string '\"'",
- "singleton : '(' re ')'",
- "singleton : CHAR",
- "fullccl : '[' ccl ']'",
- "fullccl : '[' '^' ccl ']'",
- "ccl : ccl CHAR '-' CHAR",
- "ccl : ccl CHAR",
- "ccl :",
- "string : string CHAR",
- "string :",
- };
- #endif
- #ifndef YYSTYPE
- typedef int YYSTYPE;
- #endif
- #define yyclearin (yychar=(-1))
- #define yyerrok (yyerrflag=0)
- #ifndef YYSTACKSIZE
- #ifdef YYMAXDEPTH
- #define YYSTACKSIZE YYMAXDEPTH
- #else
- #define YYSTACKSIZE 300
- #endif
- #endif
- int yydebug;
- int yynerrs;
- int yyerrflag;
- int yychar;
- short *yyssp;
- YYSTYPE *yyvsp;
- YYSTYPE yyval;
- YYSTYPE yylval;
- #define yystacksize YYSTACKSIZE
- short yyss[YYSTACKSIZE];
- YYSTYPE yyvs[YYSTACKSIZE];
- #line 596 "flxparse.y"
-
-
- /* build_eof_action - build the "<<EOF>>" action for the active start
- * conditions
- */
-
- build_eof_action()
-
- {
- register int i;
-
- for ( i = 1; i <= actvp; ++i )
- {
- if ( sceof[actvsc[i]] )
- lerrsf( "multiple <<EOF>> rules for start condition %s",
- scname[actvsc[i]] );
-
- else
- {
- sceof[actvsc[i]] = true;
- fprintf( temp_action_file, "case YY_STATE_EOF(%s):\n",
- scname[actvsc[i]] );
- }
- }
-
- line_directive_out( temp_action_file );
- }
-
-
- /* synerr - report a syntax error
- *
- * synopsis
- * char str[];
- * synerr( str );
- */
-
- synerr( str )
- char str[];
-
- {
- syntaxerror = true;
- fprintf( stderr, "Syntax error at line %d: %s\n", linenum, str );
- }
-
-
- /* yyerror - eat up an error message from the parser
- *
- * synopsis
- * char msg[];
- * yyerror( msg );
- */
-
- yyerror( msg )
- char msg[];
-
- {
- }
-
-
-
- #line 309 "y_tab.c"
- #define YYABORT goto yyabort
- #define YYACCEPT goto yyaccept
- #define YYERROR goto yyerrlab
- int
- yyparse()
- {
- register int yym, yyn, yystate;
- #if YYDEBUG
- register char *yys;
- extern char *getenv();
-
- if (yys = getenv("YYDEBUG"))
- {
- yyn = *yys;
- if (yyn >= '0' && yyn <= '9')
- yydebug = yyn - '0';
- }
- #endif
-
- yynerrs = 0;
- yyerrflag = 0;
- yychar = (-1);
-
- yyssp = yyss;
- yyvsp = yyvs;
- *yyssp = yystate = 0;
-
- yyloop:
- if (yyn = yydefred[yystate]) goto yyreduce;
- if (yychar < 0)
- {
- if ((yychar = yylex()) < 0) yychar = 0;
- #if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("yydebug: state %d, reading %d (%s)\n", yystate,
- yychar, yys);
- }
- #endif
- }
- if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
- {
- #if YYDEBUG
- if (yydebug)
- printf("yydebug: state %d, shifting to state %d\n",
- yystate, yytable[yyn]);
- #endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate = yytable[yyn];
- *++yyvsp = yylval;
- yychar = (-1);
- if (yyerrflag > 0) --yyerrflag;
- goto yyloop;
- }
- if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
- {
- yyn = yytable[yyn];
- goto yyreduce;
- }
- if (yyerrflag) goto yyinrecovery;
- #ifdef lint
- goto yynewerror;
- #endif
- yynewerror:
- yyerror("syntax error");
- #ifdef lint
- goto yyerrlab;
- #endif
- yyerrlab:
- ++yynerrs;
- yyinrecovery:
- if (yyerrflag < 3)
- {
- yyerrflag = 3;
- for (;;)
- {
- if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
- {
- #if YYDEBUG
- if (yydebug)
- printf("yydebug: state %d, error recovery shifting\
- to state %d\n", *yyssp, yytable[yyn]);
- #endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate = yytable[yyn];
- *++yyvsp = yylval;
- goto yyloop;
- }
- else
- {
- #if YYDEBUG
- if (yydebug)
- printf("yydebug: error recovery discarding state %d\n",
- *yyssp);
- #endif
- if (yyssp <= yyss) goto yyabort;
- --yyssp;
- --yyvsp;
- }
- }
- }
- else
- {
- if (yychar == 0) goto yyabort;
- #if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("yydebug: state %d, error recovery discards token %d (%s)\n",
- yystate, yychar, yys);
- }
- #endif
- yychar = (-1);
- goto yyloop;
- }
- yyreduce:
- #if YYDEBUG
- if (yydebug)
- printf("yydebug: state %d, reducing by rule %d (%s)\n",
- yystate, yyn, yyrule[yyn]);
- #endif
- yym = yylen[yyn];
- yyval = yyvsp[1-yym];
- switch (yyn)
- {
- case 1:
- #line 55 "flxparse.y"
- { /* add default rule */
- int def_rule;
-
- pat = cclinit();
- cclnegate( pat );
-
- def_rule = mkstate( -pat );
-
- finish_rule( def_rule, false, 0, 0 );
-
- for ( i = 1; i <= lastsc; ++i )
- scset[i] = mkbranch( scset[i], def_rule );
-
- if ( spprdflt )
- fputs( "YY_FATAL_ERROR( \"flex scanner jammed\" )",
- temp_action_file );
- else
- fputs( "ECHO", temp_action_file );
-
- fputs( ";\n\tYY_BREAK\n", temp_action_file );
- }
- break;
- case 2:
- #line 79 "flxparse.y"
- {
- /* initialize for processing rules */
-
- /* create default DFA start condition */
- scinstal( "INITIAL", false );
- }
- break;
- case 5:
- #line 90 "flxparse.y"
- { synerr( "unknown error processing section 1" ); }
- break;
- case 7:
- #line 97 "flxparse.y"
- {
- /* these productions are separate from the s1object
- * rule because the semantics must be done before
- * we parse the remainder of an s1object
- */
-
- xcluflg = false;
- }
- break;
- case 8:
- #line 107 "flxparse.y"
- { xcluflg = true; }
- break;
- case 9:
- #line 111 "flxparse.y"
- { scinstal( nmstr, xcluflg ); }
- break;
- case 10:
- #line 114 "flxparse.y"
- { scinstal( nmstr, xcluflg ); }
- break;
- case 11:
- #line 117 "flxparse.y"
- { synerr( "bad start condition list" ); }
- break;
- case 14:
- #line 125 "flxparse.y"
- {
- /* initialize for a parse of one rule */
- trlcontxt = variable_trail_rule = varlength = false;
- trailcnt = headcnt = rulelen = 0;
- current_state_type = STATE_NORMAL;
- previous_continued_action = continued_action;
- new_rule();
- }
- break;
- case 15:
- #line 136 "flxparse.y"
- {
- pat = link_machines( yyvsp[-1], yyvsp[0] );
- finish_rule( pat, variable_trail_rule,
- headcnt, trailcnt );
-
- for ( i = 1; i <= actvp; ++i )
- scbol[actvsc[i]] =
- mkbranch( scbol[actvsc[i]], pat );
-
- if ( ! bol_needed )
- {
- bol_needed = true;
-
- if ( performance_report )
- fprintf( stderr,
- "'^' operator results in sub-optimal performance\n" );
- }
- }
- break;
- case 16:
- #line 156 "flxparse.y"
- {
- pat = link_machines( yyvsp[-1], yyvsp[0] );
- finish_rule( pat, variable_trail_rule,
- headcnt, trailcnt );
-
- for ( i = 1; i <= actvp; ++i )
- scset[actvsc[i]] =
- mkbranch( scset[actvsc[i]], pat );
- }
- break;
- case 17:
- #line 167 "flxparse.y"
- {
- pat = link_machines( yyvsp[-1], yyvsp[0] );
- finish_rule( pat, variable_trail_rule,
- headcnt, trailcnt );
-
- /* add to all non-exclusive start conditions,
- * including the default (0) start condition
- */
-
- for ( i = 1; i <= lastsc; ++i )
- if ( ! scxclu[i] )
- scbol[i] = mkbranch( scbol[i], pat );
-
- if ( ! bol_needed )
- {
- bol_needed = true;
-
- if ( performance_report )
- fprintf( stderr,
- "'^' operator results in sub-optimal performance\n" );
- }
- }
- break;
- case 18:
- #line 191 "flxparse.y"
- {
- pat = link_machines( yyvsp[-1], yyvsp[0] );
- finish_rule( pat, variable_trail_rule,
- headcnt, trailcnt );
-
- for ( i = 1; i <= lastsc; ++i )
- if ( ! scxclu[i] )
- scset[i] = mkbranch( scset[i], pat );
- }
- break;
- case 19:
- #line 202 "flxparse.y"
- { build_eof_action(); }
- break;
- case 20:
- #line 205 "flxparse.y"
- {
- /* this EOF applies only to the INITIAL start cond. */
- actvsc[actvp = 1] = 1;
- build_eof_action();
- }
- break;
- case 21:
- #line 212 "flxparse.y"
- { synerr( "unrecognized rule" ); }
- break;
- case 23:
- #line 219 "flxparse.y"
- {
- if ( (scnum = sclookup( nmstr )) == 0 )
- lerrsf( "undeclared start condition %s", nmstr );
-
- else
- actvsc[++actvp] = scnum;
- }
- break;
- case 24:
- #line 228 "flxparse.y"
- {
- if ( (scnum = sclookup( nmstr )) == 0 )
- lerrsf( "undeclared start condition %s", nmstr );
- else
- actvsc[actvp = 1] = scnum;
- }
- break;
- case 25:
- #line 236 "flxparse.y"
- { synerr( "bad start condition list" ); }
- break;
- case 26:
- #line 240 "flxparse.y"
- {
- if ( trlcontxt )
- {
- synerr( "trailing context used twice" );
- yyval = mkstate( SYM_EPSILON );
- }
- else
- {
- trlcontxt = true;
-
- if ( ! varlength )
- headcnt = rulelen;
-
- ++rulelen;
- trailcnt = 1;
-
- eps = mkstate( SYM_EPSILON );
- yyval = link_machines( eps, mkstate( '\n' ) );
- }
- }
- break;
- case 27:
- #line 262 "flxparse.y"
- {
- yyval = mkstate( SYM_EPSILON );
-
- if ( trlcontxt )
- {
- if ( varlength && headcnt == 0 )
- /* both head and trail are variable-length */
- variable_trail_rule = true;
- else
- trailcnt = rulelen;
- }
- }
- break;
- case 28:
- #line 277 "flxparse.y"
- {
- varlength = true;
-
- yyval = mkor( yyvsp[-2], yyvsp[0] );
- }
- break;
- case 29:
- #line 284 "flxparse.y"
- {
- if ( transchar[lastst[yyvsp[0]]] != SYM_EPSILON )
- /* provide final transition \now/ so it
- * will be marked as a trailing context
- * state
- */
- yyvsp[0] = link_machines( yyvsp[0], mkstate( SYM_EPSILON ) );
-
- mark_beginning_as_normal( yyvsp[0] );
- current_state_type = STATE_NORMAL;
-
- if ( previous_continued_action )
- {
- /* we need to treat this as variable trailing
- * context so that the backup does not happen
- * in the action but before the action switch
- * statement. If the backup happens in the
- * action, then the rules "falling into" this
- * one's action will *also* do the backup,
- * erroneously.
- */
- if ( ! varlength || headcnt != 0 )
- {
- fprintf( stderr,
- "flex: warning - trailing context rule at line %d made variable because\n",
- linenum );
- fprintf( stderr,
- " of preceding '|' action\n" );
- }
-
- /* mark as variable */
- varlength = true;
- headcnt = 0;
- }
-
- if ( varlength && headcnt == 0 )
- { /* variable trailing context rule */
- /* mark the first part of the rule as the accepting
- * "head" part of a trailing context rule
- */
- /* by the way, we didn't do this at the beginning
- * of this production because back then
- * current_state_type was set up for a trail
- * rule, and add_accept() can create a new
- * state ...
- */
- add_accept( yyvsp[-1], num_rules | YY_TRAILING_HEAD_MASK );
- }
-
- yyval = link_machines( yyvsp[-1], yyvsp[0] );
- }
- break;
- case 30:
- #line 337 "flxparse.y"
- { yyval = yyvsp[0]; }
- break;
- case 31:
- #line 342 "flxparse.y"
- {
- /* this rule is separate from the others for "re" so
- * that the reduction will occur before the trailing
- * series is parsed
- */
-
- if ( trlcontxt )
- synerr( "trailing context used twice" );
- else
- trlcontxt = true;
-
- if ( varlength )
- /* we hope the trailing context is fixed-length */
- varlength = false;
- else
- headcnt = rulelen;
-
- rulelen = 0;
-
- current_state_type = STATE_TRAILING_CONTEXT;
- yyval = yyvsp[-1];
- }
- break;
- case 32:
- #line 367 "flxparse.y"
- {
- /* this is where concatenation of adjacent patterns
- * gets done
- */
- yyval = link_machines( yyvsp[-1], yyvsp[0] );
- }
- break;
- case 33:
- #line 375 "flxparse.y"
- { yyval = yyvsp[0]; }
- break;
- case 34:
- #line 379 "flxparse.y"
- {
- varlength = true;
-
- yyval = mkclos( yyvsp[-1] );
- }
- break;
- case 35:
- #line 386 "flxparse.y"
- {
- varlength = true;
-
- yyval = mkposcl( yyvsp[-1] );
- }
- break;
- case 36:
- #line 393 "flxparse.y"
- {
- varlength = true;
-
- yyval = mkopt( yyvsp[-1] );
- }
- break;
- case 37:
- #line 400 "flxparse.y"
- {
- varlength = true;
-
- if ( yyvsp[-3] > yyvsp[-1] || yyvsp[-3] < 0 )
- {
- synerr( "bad iteration values" );
- yyval = yyvsp[-5];
- }
- else
- {
- if ( yyvsp[-3] == 0 )
- yyval = mkopt( mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] ) );
- else
- yyval = mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] );
- }
- }
- break;
- case 38:
- #line 418 "flxparse.y"
- {
- varlength = true;
-
- if ( yyvsp[-2] <= 0 )
- {
- synerr( "iteration value must be positive" );
- yyval = yyvsp[-4];
- }
-
- else
- yyval = mkrep( yyvsp[-4], yyvsp[-2], INFINITY );
- }
- break;
- case 39:
- #line 432 "flxparse.y"
- {
- /* the singleton could be something like "(foo)",
- * in which case we have no idea what its length
- * is, so we punt here.
- */
- varlength = true;
-
- if ( yyvsp[-1] <= 0 )
- {
- synerr( "iteration value must be positive" );
- yyval = yyvsp[-3];
- }
-
- else
- yyval = link_machines( yyvsp[-3], copysingl( yyvsp[-3], yyvsp[-1] - 1 ) );
- }
- break;
- case 40:
- #line 450 "flxparse.y"
- {
- if ( ! madeany )
- {
- /* create the '.' character class */
- anyccl = cclinit();
- ccladd( anyccl, '\n' );
- cclnegate( anyccl );
-
- if ( useecs )
- mkeccl( ccltbl + cclmap[anyccl],
- ccllen[anyccl], nextecm,
- ecgroup, CSIZE );
-
- madeany = true;
- }
-
- ++rulelen;
-
- yyval = mkstate( -anyccl );
- }
- break;
- case 41:
- #line 472 "flxparse.y"
- {
- if ( ! cclsorted )
- /* sort characters for fast searching. We use a
- * shell sort since this list could be large.
- */
- cshell( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]] );
-
- if ( useecs )
- mkeccl( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]],
- nextecm, ecgroup, CSIZE );
-
- ++rulelen;
-
- yyval = mkstate( -yyvsp[0] );
- }
- break;
- case 42:
- #line 489 "flxparse.y"
- {
- ++rulelen;
-
- yyval = mkstate( -yyvsp[0] );
- }
- break;
- case 43:
- #line 496 "flxparse.y"
- { yyval = yyvsp[-1]; }
- break;
- case 44:
- #line 499 "flxparse.y"
- { yyval = yyvsp[-1]; }
- break;
- case 45:
- #line 502 "flxparse.y"
- {
- ++rulelen;
-
- if ( yyvsp[0] == '\0' )
- synerr( "null in rule" );
-
- if ( caseins && yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
- yyvsp[0] = clower( yyvsp[0] );
-
- yyval = mkstate( yyvsp[0] );
- }
- break;
- case 46:
- #line 516 "flxparse.y"
- { yyval = yyvsp[-1]; }
- break;
- case 47:
- #line 519 "flxparse.y"
- {
- /* *Sigh* - to be compatible Unix lex, negated ccls
- * match newlines
- */
- #ifdef NOTDEF
- ccladd( yyvsp[-1], '\n' ); /* negated ccls don't match '\n' */
- cclsorted = false; /* because we added the newline */
- #endif
- cclnegate( yyvsp[-1] );
- yyval = yyvsp[-1];
- }
- break;
- case 48:
- #line 533 "flxparse.y"
- {
- if ( yyvsp[-2] > yyvsp[0] )
- synerr( "negative range in character class" );
-
- else
- {
- if ( caseins )
- {
- if ( yyvsp[-2] >= 'A' && yyvsp[-2] <= 'Z' )
- yyvsp[-2] = clower( yyvsp[-2] );
- if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
- yyvsp[0] = clower( yyvsp[0] );
- }
-
- for ( i = yyvsp[-2]; i <= yyvsp[0]; ++i )
- ccladd( yyvsp[-3], i );
-
- /* keep track if this ccl is staying in alphabetical
- * order
- */
- cclsorted = cclsorted && (yyvsp[-2] > lastchar);
- lastchar = yyvsp[0];
- }
-
- yyval = yyvsp[-3];
- }
- break;
- case 49:
- #line 561 "flxparse.y"
- {
- if ( caseins )
- if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
- yyvsp[0] = clower( yyvsp[0] );
-
- ccladd( yyvsp[-1], yyvsp[0] );
- cclsorted = cclsorted && (yyvsp[0] > lastchar);
- lastchar = yyvsp[0];
- yyval = yyvsp[-1];
- }
- break;
- case 50:
- #line 573 "flxparse.y"
- {
- cclsorted = true;
- lastchar = 0;
- yyval = cclinit();
- }
- break;
- case 51:
- #line 581 "flxparse.y"
- {
- if ( caseins )
- if ( yyvsp[0] >= 'A' && yyvsp[0] <= 'Z' )
- yyvsp[0] = clower( yyvsp[0] );
-
- ++rulelen;
-
- yyval = link_machines( yyvsp[-1], mkstate( yyvsp[0] ) );
- }
- break;
- case 52:
- #line 592 "flxparse.y"
- { yyval = mkstate( SYM_EPSILON ); }
- break;
- #line 1007 "y_tab.c"
- }
- yyssp -= yym;
- yystate = *yyssp;
- yyvsp -= yym;
- yym = yylhs[yyn];
- if (yystate == 0 && yym == 0)
- {
- #ifdef YYDEBUG
- if (yydebug)
- printf("yydebug: after reduction, shifting from state 0 to\
- state %d\n", YYFINAL);
- #endif
- yystate = YYFINAL;
- *++yyssp = YYFINAL;
- *++yyvsp = yyval;
- if (yychar < 0)
- {
- if ((yychar = yylex()) < 0) yychar = 0;
- #if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("yydebug: state %d, reading %d (%s)\n",
- YYFINAL, yychar, yys);
- }
- #endif
- }
- if (yychar == 0) goto yyaccept;
- goto yyloop;
- }
- if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
- yystate = yytable[yyn];
- else
- yystate = yydgoto[yym];
- #ifdef YYDEBUG
- if (yydebug)
- printf("yydebug: after reduction, shifting from state %d \
- to state %d\n", *yyssp, yystate);
- #endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate;
- *++yyvsp = yyval;
- goto yyloop;
- yyoverflow:
- yyerror("yacc stack overflow");
- yyabort:
- return (1);
- yyaccept:
- return (0);
- }
-